package config.initialization;

import config.MvcConfig;
import config.db.MongodbConfiguration;
import config.security.WebFluxSecurityConfig;
import org.springframework.web.server.adapter.AbstractReactiveWebInitializer;

public class SpittrWebAppInitializer extends AbstractReactiveWebInitializer {
    @Override
    protected Class<?>[] getConfigClasses() {
        return new Class[]{MvcConfig.class, MongodbConfiguration.class, /*RouteConfiguration.class,*/ WebFluxSecurityConfig.class, CorsConfig.class};
    }

    @Override
    protected String getServletMapping() {
        return "/";
    }
    /**
     * spring配置
     */
//    @Override
//    protected Class<?>[] getRootConfigClasses() {
//        return new Class<?>[]{SpringConfig.class, DBConfig.class, RedisConfig.class};

//    }

    /**
     * springmvc配置
     */
//    @Override
//    protected Class<?>[] getServletConfigClasses() {
//        return new Class[]{WebmvcConfig.class};
//    }

    /**
     * 拦截/
     */
//    @Override
//    protected String[] getServletMappings() {
//        return new String[]{"/"};
//    }
//    private static final long MAX_FILE_SIZE = 2097152000L; // 5MB : Max file size.
//    private static final long MAX_REQUEST_SIZE = 2097152000L;
//    private static final int FILE_SIZE_THRESHOLD = 0; // Size threshold after which files will be written to disk
//    @Override
//    protected void customizeRegistration(ServletRegistration.Dynamic registration) {
//         Optionally also set maxFileSize, maxRequestSize, fileSizeThreshold
//        MultipartConfigElement multipartConfigElement = new MultipartConfigElement(StorageServiceImpl.LOCATION, MAX_FILE_SIZE, MAX_REQUEST_SIZE, FILE_SIZE_THRESHOLD);
//
//        registration.setMultipartConfig(multipartConfigElement);
//    }
}
